<template>
    <div>
      <ul class="list">
        <li class="list_li common_bg_fff" v-for="(item,index) in list">
          <div>
            <p class="font_333_30">{{item.descri}}</p>
            <p class="time font_999_26">{{item.time}}</p>
          </div>
          <span class="font_666_36">{{item.money}}</span>
        </li>
      </ul>
    </div>
</template>

<script>
    export default {
        name: '',
        components: {},
        data() {
            return {
              title:'零钱明细',
              list:[],
              cash:1,
              page:1
            }
        },
        created () {
          this.setTitle(this.title)
          this.scorll()
        },
        mounted: function () {
          this.axios.post('/home/Recharge/cashList',{
            token:this.$store.state.token,
            page:this.page
          }).then((res)=>{
            if(res.data.code==200){
              this.list = res.data.data
            }
          })
        },
        methods: {
          scorll(a){
            let _this = this
            document.onscroll = function(){
              let scrollTop = document.documentElement.scrollTop||document.body.scrollTop;//距离顶部的距离
              let windowHeight = document.documentElement.clientHeight || document.body.clientHeight;//可视区的高度
              let scrollHeight = document.documentElement.scrollHeight||document.body.scrollHeight;//滚动条的总高度
              //滚动条到底部的条件
              if(!_this.cash) return
              if(scrollTop==0) return
              if(scrollHeight-scrollTop-windowHeight<=0){
                _this.page++
                _this.axios.post('/home/Recharge/cashList',{
                  token:_this.$store.state.token,
                  page:_this.page,
                }).then((res)=>{
                  if(res.data.code==200){
                    let list = res.data.data
                    if(list){
                      _this.noLIST = false
                      _this.list = _this.list.concat(res.data.data)
                    }else{
                      return
                    }
                  }
                })
              }
            }
          }
        },
        beforeDestroy: function(){
          this.cash = null
        },
        destroyed(){
          this.cash = null
        }
    }
</script>

<style scoped>
  @import "../../assets/public.css";
  @import "//at.alicdn.com/t/font_814275_a49o0xc0z4m.css";

  .list{
    margin-top:.2rem;
  }
  .list_li{
    height:1.48rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding:0 .34rem;
    margin-top:.1rem;
  }
  .time{
    margin-top:.29rem;
  }
</style>
